<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>告警通知</title>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            line-height: 1.6;
            color: #333;
            background-color: #f5f5f5;
            margin: 0;
            padding: 20px;
        }
        .email-container {
            max-width: 600px;
            margin: 0 auto;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
            overflow: hidden;
        }
        .email-header {
            background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
            color: #ffffff;
            padding: 30px 20px;
            text-align: center;
        }
        .email-header h1 {
            margin: 0;
            font-size: 24px;
            font-weight: 600;
        }
        .email-header .alert-icon {
            font-size: 48px;
            margin-bottom: 10px;
        }
        .email-body {
            padding: 30px 20px;
        }
        .info-section {
            margin-bottom: 25px;
        }
        .info-section h2 {
            color: #e53e3e;
            font-size: 18px;
            margin: 0 0 15px 0;
            padding-bottom: 10px;
            border-bottom: 2px solid #e53e3e;
        }
        .info-item {
            display: flex;
            padding: 10px 0;
            border-bottom: 1px solid #eee;
        }
        .info-item:last-child {
            border-bottom: none;
        }
        .info-label {
            font-weight: 600;
            color: #666;
            min-width: 100px;
        }
        .info-value {
            color: #333;
            flex: 1;
        }
        .image-section {
            margin-top: 25px;
        }
        .image-section img {
            width: 100%;
            max-width: 560px;
            height: auto;
            border-radius: 4px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        .violator-highlight {
            background-color: #fef6e0;
            padding: 15px;
            border-left: 4px solid #f6ad55;
            border-radius: 4px;
            margin: 15px 0;
        }
        .email-footer {
            background-color: #f7fafc;
            padding: 20px;
            text-align: center;
            color: #718096;
            font-size: 14px;
        }
        .timestamp {
            color: #e53e3e;
            font-weight: 600;
        }
    </style>
</head>
<body>
    <div class="email-container">
        <!-- 邮件头部 -->
        <div class="email-header">
            <div class="alert-icon">⚠️</div>
            <h1>紧急告警通知</h1>
        </div>

        <!-- 邮件正文 -->
        <div class="email-body">
            <!-- 告警图片（最重要，放在最前面） -->
            <div class="image-section" th:if="${hasImage}">
                <h2>📷 告警现场</h2>
                <!-- 使用内嵌图片（CID） -->
                <img src="cid:alarmImage" alt="告警现场图片" style="display: block;">
            </div>

            <!-- 告警基本信息 -->
            <div class="info-section">
                <h2>📋 告警信息</h2>
                <div class="info-item">
                    <span class="info-label">告警类型：</span>
                    <span class="info-value" th:text="${alarmName}">未穿工作服</span>
                </div>
                <div class="info-item">
                    <span class="info-label">告警时间：</span>
                    <span class="info-value timestamp" th:text="${alarmTime}">2025-11-07 14:30:00</span>
                </div>
            </div>

            <!-- 违规人员信息 -->
            <div th:if="${violatorName}" class="violator-highlight">
                <strong>🔍 识别到违规人员：</strong>
                <span th:text="${violatorName}">张工</span>
                <span th:if="${faceSimilarity}">（相似度: <span th:text="${faceSimilarity}">95.0%</span>）</span>
            </div>

            <!-- 设备信息 -->
            <div class="info-section">
                <h2>📍 设备信息</h2>
                <div class="info-item" th:if="${deviceName}">
                    <span class="info-label">设备名称：</span>
                    <span class="info-value" th:text="${deviceName}">设备1</span>
                </div>
                <div class="info-item" th:if="${deviceSn}">
                    <span class="info-label">设备序列号：</span>
                    <span class="info-value" th:text="${deviceSn}">DEVICE001</span>
                </div>
                <div class="info-item" th:if="${deviceLocation}">
                    <span class="info-label">设备位置：</span>
                    <span class="info-value" th:text="${deviceLocation}">生产车间A区</span>
                </div>
                <div class="info-item" th:if="${cameraName}">
                    <span class="info-label">摄像头：</span>
                    <span class="info-value" th:text="${cameraName}">摄像头1</span>
                </div>
                <div class="info-item" th:if="${cameraLocation}">
                    <span class="info-label">摄像头位置：</span>
                    <span class="info-value" th:text="${cameraLocation}">入口处</span>
                </div>
            </div>
        </div>

        <!-- 邮件底部 -->
        <div class="email-footer">
            <p>本邮件由 AI智能监控系统 自动发送，请勿回复。</p>
            <p>如有疑问，请联系系统管理员。</p>
        </div>
    </div>
</body>
</html>

